package algorithmTopics.matrix;

import java.util.*;
public class Main1 {
    static int n,m;
    static int[][] direct = {{0,-1},{0,1},{-1,0},{1,0}};

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        //换行
        sc.nextLine();

        String[][] ans = new String[n][m];
        for(int i = 0;i < n;i++){
            //读取矩阵
            ans[i] = sc.nextLine().split(" ");  
        }
        //标记哪些区域读过
        boolean[][] visited = new boolean[n][m];
        //存放符合条件结果集合
        List<pair<Integer,String>> resNode = new ArrayList<>();

        // 遍历所有节点
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                //遍历O节点，且不重复
                if(ans[i][j].equals("O") && ! visited[i][j]){
                    //存放入口的坐标
                    List<int[]> enter = new ArrayList<>();
                    int res = bfs(ans, visited, i, j, enter);
                    //是不是唯一出口
                    if (enter.size() == 1) {
                        resNode.add(new pair(res,
                        enter.get(0)[0]+ " " + enter.get(0)[1]));
                    }

                }
            }
        }
        int size = resNode.size();
        //输出结果
        if (size == 0) {
            System.out.print("NULL");
        }else if (size == 1) {
            System.out.println(resNode.get(0).getV() + " " +
            resNode.get(0).getK());
        }else{
            //多个区域
            resNode.sort((a,b) -> b.getK() - a.getK());
            //是不是有同样最大的
            if (resNode.get(0).getK() == resNode.get(1).getK()) {
                System.out.print(resNode.get(0).getK());
            }else{
                System.out.println(resNode.get(0).getV() + " " +
                resNode.get(0).getK());
            }
        }



    }

    //计算联通区域
    //返回大小，以及记录出口坐标
    public static int bfs(String[][] ans ,boolean[][] visited,
    int x,int y,List<int[]> enter){
        //用于存放联通的所有点位坐标
        Queue<int[]> queue = new ArrayDeque<>();
        queue.offer(new int[] {x,y});
        visited[x][y] = true;
        int size = 0;

        while (!queue.isEmpty()) {
            int[] now = queue.poll();
            int currentX = now[0];
            int currentY = now[1];
            size++;
            //当前坐标是不是出口
            if (currentX == 0 || currentX == n -1 || 
            currentY == 0 || currentY == m - 1) {
                enter.add(now);
            }
            // 遍历四个方向
            for (int[] d : direct) {
                //下一个方向的坐标
                int preX = currentX + d[0];
                int preY = currentY + d[1];
                //不重复 不越界 
                if (preX >= 0 && preX < n && preY >= 0 
                && preY < m && !visited[preX][preY] 
                && ans[preX][preY].equals("O") ) {
                    visited[preX][preY] = true;
                    //放入队列
                    queue.offer(new int[] {preX,preY});
                }

            }

        }

        return size;
    }

    //存储结果的类
    static class pair<K,V>{
        K k;
        V v;
        pair(K k, V v){
            this.k = k;
            this.v = v;
        }
        K getK(){return k;}
        V getV(){return v;}
    }


}